package org.come.Jpanel;

import java.awt.Dimension;
import java.awt.Graphics;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.Map;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import com.tool.image.ImageMixDeal;
import com.tool.image.ManimgAttribute;
import org.come.bean.ConfigureBean;
import org.come.model.Configure;
import org.come.mouslisten.RoleTxMouslisten;
import org.come.until.UserMessUntil;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.ImageDressBtn;
import com.tool.btn.SpecificBtn;
import com.tool.role.RoleTX;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;



public class ImageDressJpanel extends JPanel {

    private SpecificBtn btnYjxc,// 一键卸除
            btnBcxx,// 保存形象
            btnJx,// 捐献
            btnDbggm,// 多宝阁购买
            btnLeft, btnRight, btnTop, btnBottom;

    private static JLabel[] labYcd = new JLabel[4];// 已穿戴的装扮
    private static JLabel[] labImages = new JLabel[25];// 已拥有的装扮

    private ImageDressBtn btnTx,// 特效
            btnZsp,// 装饰品
            btnZj,// 足迹
            btnWing,
            btnFashion; // 翅膀

    private ImageIcon icon0;
    private ImageIcon icon1;
    private ImageIcon icon2;
    private ImageIcon icon3;
    private ImageIcon icon4;
    private ImageIcon icon5;
    private JCheckBox checkBox;

    public ImageDressJpanel() {

        ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        Configure configure = item.get(new BigDecimal(1));

        String cbkg = configure.getCbgnkg();
        if ("水墨UI".equals(MyIsif.getStyle())) {
            icon0 = new ImageIcon("inkImg/hongmu/2/imagedress_0.png");
            icon1 = new ImageIcon("inkImg/hongmu/2/imagedress_1.png");
            icon2 = new ImageIcon("inkImg/hongmu/2/imagedress_2.png");
            icon3 = new ImageIcon("inkImg/hongmu/2/imagedress_3.png");
            icon4 = new ImageIcon("inkImg/hongmu/2/imagedress_4.png");
            icon5 = new ImageIcon("inkImg/hongmu/2/imagedress_5.png");
            this.setPreferredSize(new Dimension(622, 409));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);
            // 关闭按钮事件
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 38);
            offBtn.setBounds(622 - 37, 10, 25, 25);
            this.add(offBtn);

            // 已穿戴的装扮
            for (int i = 0; i < labYcd.length; i++) {
                labYcd[i] = new JLabel();
                labYcd[i].addMouseListener(new RoleTxMouslisten(-(i + 1)));
                labYcd[i].setBounds(59, 108 + i * 45, 39, 39);
                this.add(labYcd[i]);
            }

            // 已拥有的装扮
            for (int i = 0; i < 25; i++) {
                int row = i % 5;
                int col = i / 5;
                labImages[i] = new JLabel();
                labImages[i].addMouseListener(new RoleTxMouslisten(i));
                labImages[i].setBounds(330 + row * 51, 97 + col * 51, 49, 49);
                this.add(labImages[i]);
            }

            // 一键卸除
            btnYjxc = new SpecificBtn("skin/8100226/button/49.png", 1, UIUtils.COLOR_BTNTEXT, "一键卸除", 2);
            btnYjxc.setBounds(108, 365, 68, 17);
            this.add(btnYjxc);

            // 保存形象
            btnBcxx = new SpecificBtn("skin/8100226/button/49.png", 1, UIUtils.COLOR_BTNTEXT, "保存形象", 3);
            btnBcxx.setBounds(239, 365, 68, 17);
            this.add(btnBcxx);

            // 捐献
            // 	btnJx = new SpecificBtn(imageMap.getImgMap().get("B20"),"B20", 1,UIUtils.COLOR_BLACK,"捐献", 4);
            // 	btnJx.setBounds(325, 355, 59, 24);
            // 	this.add(btnJx);
            // 多宝阁购买
            // 	btnDbggm = new SpecificBtn(imageMap.getImgMap().get("B22"),"B22", 1,UIUtils.COLOR_BLACK, "多宝阁购买", 5);
            // 	btnDbggm.setBounds(492, 355, 99, 24);
            // 	this.add(btnDbggm);

            btnLeft = new SpecificBtn("skin/8100226/button/12.png", 1, "", 6);
            btnLeft.setBounds(165 + 18, 366, 11, 15);
            this.add(btnLeft);

            btnRight = new SpecificBtn("skin/8100226/button/11.png", 1, "", 7);
            btnRight.setBounds(194 + 30, 366, 11, 15);
            this.add(btnRight);

            btnTop = new SpecificBtn("skin/8100226/button/B42.png", 1, "", 8);
            btnTop.setBounds(580, 300, 19, 20);
            this.add(btnTop);

            btnBottom = new SpecificBtn("skin/8100226/button/B43.png", 1, "", 9);
            btnBottom.setBounds(580, 320, 19, 20);
            this.add(btnBottom);

            // 特效
            btnTx = new ImageDressBtn("skin/8100226/button/B120.png", 1, 1, "", this);
            btnTx.setBounds(325, 85 - 26, 63, 26);
            this.add(btnTx);

            // 装饰品
            btnZsp = new ImageDressBtn("skin/8100226/button/B121.png", 1, 2, "", this);
            btnZsp.setBounds(325 + 65 * 1, 85 - 26, 63, 26);
            this.add(btnZsp);

            // 足迹
            btnZj = new ImageDressBtn("skin/8100226/button/B123.png", 1, 3, "", this);
            btnZj.setBounds(325 + 65 * 2, 85 - 26, 63, 26);
            this.add(btnZj);


            if ("开".equals(cbkg)) {
                // 翅膀
                btnWing = new ImageDressBtn("skin/8100226/button/B125.png", 1, 4, "", this);
                btnWing.setBounds(325 + 65 * 3, 85 - 26, 63, 26);
                this.add(btnWing);
            }
        } else {
            icon0 = new ImageIcon("inkImg/hongmu/2/imagedress_0.png");
            icon1 = new ImageIcon("inkImg/hongmu/2/imagedress_1.png");
            icon2 = new ImageIcon("inkImg/hongmu/2/imagedress_2.png");
            icon3 = new ImageIcon("inkImg/hongmu/2/imagedress_3.png");
            icon4 = new ImageIcon("inkImg/hongmu/2/imagedress_4.png");
            icon5 = new ImageIcon("inkImg/hongmu/2/imagedress_5.png");
            this.setPreferredSize(new Dimension(596, 457));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);
            // 关闭按钮事件
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/hongmu/1/s74.png", 1, 38);
            offBtn.setBounds(570, 0, 25, 25);
            this.add(offBtn);

            // 已穿戴的装扮
            for (int i = 0; i < labYcd.length; i++) {
                labYcd[i] = new JLabel();
                labYcd[i].addMouseListener(new RoleTxMouslisten(-(i + 1)));
                labYcd[i].setBounds(50, 100 + i * 45, 39, 39);
                this.add(labYcd[i]);
            }

            // 已拥有的装扮
            for (int i = 0; i < 25; i++) {
                int row = i % 5;
                int col = i / 5;
                labImages[i] = new JLabel();
                labImages[i].addMouseListener(new RoleTxMouslisten(i));
                labImages[i].setBounds(304 + row * 51, 135 + col * 51, 49, 49);
                this.add(labImages[i]);
            }

            // 一键卸除
            btnYjxc = new SpecificBtn("inkImg/hongmu/1/a7.png", 1, UIUtils.COLOR_BTNPUTONG2,"一键卸除", 2);
            btnYjxc.setBounds(211, 400, 68, 26);
            this.add(btnYjxc);

            // 保存形象
            btnBcxx = new SpecificBtn("inkImg/hongmu/1/a7.png", 1,UIUtils.COLOR_BTNPUTONG2, "保存形象", 3);
            btnBcxx.setBounds(112, 400, 68, 26);
            this.add(btnBcxx);

            // 捐献
            //btnJx = new SpecificBtn("skin/8100226/button/B59.png", 1,UIUtils.COLOR_BTNPUTONG,"捐献", 4);
            //btnJx.setBounds(325, 355, 68, 26);
            //this.add(btnJx);
            // 多宝阁购买
            //btnDbggm = new SpecificBtn("skin/8100226/button/B60.png", 1,UIUtils.COLOR_BTNPUTONG, "多宝阁购买", 5);
            //btnDbggm.setBounds(492, 355, 92, 26);
            //this.add(btnDbggm);

            btnLeft = new SpecificBtn("inkImg/hongmu/2/26_png.button.btn_left.png", 1, "", 6);
            btnLeft.setBounds(165, 356, 11, 15);
            this.add(btnLeft);

            btnRight = new SpecificBtn("inkImg/hongmu/2/54_png.button.btn_right.png", 1, "", 7);
            btnRight.setBounds(194, 356, 11, 15);
            this.add(btnRight);

            btnTop = new SpecificBtn("inkImg/hongmu/2/42_png.button.btn_1.png", 1, "", 8);
            btnTop.setBounds(560, 344, 19, 20);
            this.add(btnTop);

            btnBottom = new SpecificBtn("inkImg/hongmu/2/34_png.button.xy_vscroll$down.png", 1, "", 9);
            btnBottom.setBounds(560, 368, 19, 20);
            this.add(btnBottom);

            // 特效
            btnTx = new ImageDressBtn("inkImg/hongmu/2/imagedress_1.png", 1, 1, "", this);
            btnTx.setBounds(301, 72, 63, 26);
            this.add(btnTx);

            // 装饰品
            btnZsp = new ImageDressBtn("inkImg/hongmu/2/imagedress_3.png", 1, 2, "", this);
            btnZsp.setBounds(366, 72, 63, 26);
            this.add(btnZsp);

            // 足迹
            btnZj = new ImageDressBtn("inkImg/hongmu/2/imagedress_5.png", 1, 3, "", this);
            btnZj.setBounds(431, 72, 63, 26);
            this.add(btnZj);

            if ("开".equals(cbkg)) {
                // 翅膀
                btnWing = new ImageDressBtn("inkImg/hongmu/2/imagedress_7.png", 1, 4, "", this);
                btnWing.setBounds(496, 72, 63, 26);
                this.add(btnWing);
            }
        }
    }

    private ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        super.paintComponent(g);
        if ("水墨UI".equals(MyIsif.getStyle())) {
            if (icon == null) {
                icon = new ImageIcon("inkImg/newbackground/B253.png");
            }
            g.drawImage(icon.getImage(), 0, 0, 622, 409, this);
            RoleTX.getRoleTX().draw(g, 0);
        } else {
            if (icon == null) {
                icon = new ImageIcon("inkImg/hongmu/2/imagedressjpanel.png");
            }
            g.drawImage(icon.getImage(), 0, 0, 596, 457, this);
            RoleTX.getRoleTX().draw(g, 0);
        }
    }

    public static JLabel[] getLabYcd() {
        return labYcd;
    }

    public static void setLabYcd(JLabel[] labYcd) {
        ImageDressJpanel.labYcd = labYcd;
    }

    public static JLabel[] getLabImages() {
        return labImages;
    }

    public static void setLabImages(JLabel[] labImages) {
        ImageDressJpanel.labImages = labImages;
    }

    public ImageDressBtn getBtnTx() {
        return btnTx;
    }

    public void setBtnTx(ImageDressBtn btnTx) {
        this.btnTx = btnTx;
    }

    public ImageDressBtn getBtnZsp() {
        return btnZsp;
    }

    public void setBtnZsp(ImageDressBtn btnZsp) {
        this.btnZsp = btnZsp;
    }

    public ImageDressBtn getBtnZj() {
        return btnZj;
    }

    public void setBtnZj(ImageDressBtn btnZj) {
        this.btnZj = btnZj;
    }

    public ImageDressBtn getBtnWing() {
        return btnWing;
    }

    public void setBtnWing(ImageDressBtn btnWing) {
        this.btnWing = btnWing;
    }

    public SpecificBtn getBtnYjxc() {
        return btnYjxc;
    }

    public void setBtnYjxc(SpecificBtn btnYjxc) {
        this.btnYjxc = btnYjxc;
    }

    public SpecificBtn getBtnBcxx() {
        return btnBcxx;
    }

    public void setBtnBcxx(SpecificBtn btnBcxx) {
        this.btnBcxx = btnBcxx;
    }

    public SpecificBtn getBtnJx() {
        return btnJx;
    }

    public void setBtnJx(SpecificBtn btnJx) {
        this.btnJx = btnJx;
    }

    public SpecificBtn getBtnDbggm() {
        return btnDbggm;
    }

    public void setBtnDbggm(SpecificBtn btnDbggm) {
        this.btnDbggm = btnDbggm;
    }

    public SpecificBtn getBtnLeft() {
        return btnLeft;
    }

    public void setBtnLeft(SpecificBtn btnLeft) {
        this.btnLeft = btnLeft;
    }

    public SpecificBtn getBtnRight() {
        return btnRight;
    }

    public void setBtnRight(SpecificBtn btnRight) {
        this.btnRight = btnRight;
    }

    public SpecificBtn getBtnTop() {
        return btnTop;
    }

    public void setBtnTop(SpecificBtn btnTop) {
        this.btnTop = btnTop;
    }

    public SpecificBtn getBtnBottom() {
        return btnBottom;
    }

    public void setBtnBottom(SpecificBtn btnBottom) {
        this.btnBottom = btnBottom;
    }

    public ImageIcon getIcon0() {
        return icon0;
    }

    public void setIcon0(ImageIcon icon0) {
        this.icon0 = icon0;
    }

    public ImageIcon getIcon1() {
        return icon1;
    }

    public void setIcon1(ImageIcon icon1) {
        this.icon1 = icon1;
    }

    public ImageIcon getIcon2() {
        return icon2;
    }

    public void setIcon2(ImageIcon icon2) {
        this.icon2 = icon2;
    }

    public ImageIcon getIcon3() {
        return icon3;
    }

    public void setIcon3(ImageIcon icon3) {
        this.icon3 = icon3;
    }

    public ImageIcon getIcon4() {
        return icon4;
    }

    public void setIcon4(ImageIcon icon4) {
        this.icon4 = icon4;
    }

    public ImageIcon getIcon5() {
        return icon5;
    }

    public void setIcon5(ImageIcon icon5) {
        this.icon5 = icon5;
    }

    public ImageIcon getIcon() {
        return icon;
    }

    public void setIcon(ImageIcon icon) {
        this.icon = icon;
    }

    public JCheckBox getJCheckBox() {
        if (this.checkBox == null) {
            ImageIcon icon = new ImageIcon("inkImg/background/B461.png");
            ImageIcon selectIcon = new ImageIcon("inkImg/background/B460.png");
            this.checkBox = new JCheckBox(icon, false);
            this.checkBox.setBackground(UIUtils.Color_BACK);
            this.checkBox.setSelectedIcon(selectIcon);
            this.checkBox.setBounds(5, 15, 20, 20);
            this.checkBox.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    ImageMixDeal.userimg.changeskin((String)null);
                    Iterator var2 = ImageMixDeal.Playerimgmap.values().iterator();

                    while(var2.hasNext()) {
                        ManimgAttribute value = (ManimgAttribute)var2.next();
                        value.changeskin((String)null);
                    }

                }
            });
            this.add(this.checkBox);
        }

        return this.checkBox;
    }
}
